#pragma once
#include <iostream>
#include <fcntl.h>
#include <unistd.h>

#define Die(code)   \
    do              \
    {                   \
        exit(code);     \
    } while (0);        \

#define CONV(v) (struct sockaddr*)(v)

enum
{
    USAGE_ERR = 1,
    SOCKET_ERR,
    BIND_ERR,
    LISTEN_ERR,
    ACCEPTER_ERR,
    EPOLL_CREATE_ERR,
    EPOLL_CTL_ERR
};


const int gdefaultsockfd = -1;
const int gbacklog = 8;

void SetNonBlock(int sockfd)
{
    int f1 = fcntl(sockfd, F_GETFL);
    if(f1 < 0)
    {
        return ;
    }
    fcntl(sockfd, F_SETFL, f1 | O_NONBLOCK);
}